Change in openvpn[master]: status: Avoid conversion warnings in status_read
A message that is not in the archive (sent off-list or not yet received): gerrit.1769015758000.Iff1343a2f8cc7e32b8f36b359a00248e4dc3e8c9@...2715...
Attention is currently required from: plaisthos.
Hello plaisthos,
I'd like you to do a code review.
Please visit
http://gerrit.openvpn.net/c/openvpn/+/1485?usp=email
to review the following change.
Change subject: status: Avoid conversion warnings in status_read
......................................................................
status: Avoid conversion warnings in status_read
Just use explicit casts. len is limited by BCAP and c is limited by being from buf_read_u8. So they are safe.
---
M src/openvpn/status.c
1 file changed, 3 insertions(+), 14 deletions(-)
git pull ssh://gerrit.openvpn.net:29418/openvpn refs/changes/85/1485/1
src/openvpn/status.c +3 -14
@@ -206,11 +206,6 @@return ret; } -#if defined(__GNUC__) || defined(__clang__) -#pragma GCC diagnostic push -#pragma GCC diagnostic ignored "-Wconversion" -#endif -#define STATUS_PRINTF_MAXLEN 512void
@@ -274,16 +269,14 @@/* read more of file into buffer */ if (c ==-1 ) { -int len; -ASSERT (buf_init (&so->read_buf,0 )); - len =read (so->fd,BPTR (&so->read_buf),BCAP (&so->read_buf)); +ssize_t len =read (so->fd,BPTR (&so->read_buf),BCAP (&so->read_buf));if (len <=0 ) {break ; } -ASSERT (buf_inc_len (&so->read_buf, len)); +ASSERT (buf_inc_len (&so->read_buf, (int )len));continue ; }
@@ -299,7 +292,7 @@break ; } -buf_write_u8 (buf, c); +buf_write_u8 (buf, (uint8_t )c); }buf_null_terminate (buf);
@@ -307,7 +300,3 @@return ret; } - -#if defined(__GNUC__) || defined(__clang__) -#pragma GCC diagnostic pop -#endif
--
To view, visit http://gerrit.openvpn.net/c/openvpn/+/1485?usp=email
To unsubscribe, or for help writing mail filters, visit http://gerrit.openvpn.net/settings?usp=email
Gerrit-MessageType: newchange
Gerrit-Project: openvpn
Gerrit-Branch: master
Gerrit-Change-Id: Iff1343a2f8cc7e32b8f36b359a00248e4dc3e8c9
Gerrit-Change-Number: 1485
Gerrit-PatchSet: 1
Gerrit-Owner: flichtenheld <[email protected]...>
Gerrit-Reviewer: plaisthos <[email protected]...>
Gerrit-CC: openvpn-devel <[email protected]>
Gerrit-Attention: plaisthos <[email protected]...>
Attention is currently required from: flichtenheld.
plaisthos has posted comments on this change by flichtenheld. ( http://gerrit.openvpn.net/c/openvpn/+/1485?usp=email )
Change subject: status: Avoid conversion warnings in status_read
......................................................................
Patch Set 1: Code-Review+2
--
To view, visit http://gerrit.openvpn.net/c/openvpn/+/1485?usp=email
To unsubscribe, or for help writing mail filters, visit http://gerrit.openvpn.net/settings?usp=email
Gerrit-MessageType: comment
Gerrit-Project: openvpn
Gerrit-Branch: master
Gerrit-Change-Id: Iff1343a2f8cc7e32b8f36b359a00248e4dc3e8c9
Gerrit-Change-Number: 1485
Gerrit-PatchSet: 1
Gerrit-Owner: flichtenheld <[email protected]...>
Gerrit-Reviewer: plaisthos <[email protected]...>
Gerrit-CC: openvpn-devel <[email protected]>
Gerrit-Attention: flichtenheld <[email protected]...>
Gerrit-Comment-Date: Thu, 22 Jan 2026 12:43:25 +0000
Gerrit-HasComments: No
Gerrit-Has-Labels: Yes
[Openvpn-devel] [S] Change in openvpn[master]: status: Avoid conversion warnings in status_read/status_printf
In reply to a message not in the archiveAttention is currently required from: flichtenheld, plaisthos.
Hello plaisthos,
I'd like you to reexamine a change. Please visit
http://gerrit.openvpn.net/c/openvpn/+/1485?usp=email
to look at the new patch set (#2).
The following approvals got outdated and were removed:
Code-Review+2 by plaisthos
Change subject: status: Avoid conversion warnings in status_read/status_printf
......................................................................
status: Avoid conversion warnings in status_read/status_printf
Just use explicit casts. len is limited by BCAP and c is limited by being from buf_read_u8. So they are safe.
In case of status_printf this is only for Windows. len is limited by sizeof(buf), so also a safe cast.
---
M src/openvpn/status.c
1 file changed, 4 insertions(+), 15 deletions(-)
git pull ssh://gerrit.openvpn.net:29418/openvpn refs/changes/85/1485/2
src/openvpn/status.c +4 -15
@@ -206,11 +206,6 @@return ret; } -#if defined(__GNUC__) || defined(__clang__) -#pragma GCC diagnostic push -#pragma GCC diagnostic ignored "-Wconversion" -#endif -#define STATUS_PRINTF_MAXLEN 512void
@@ -243,7 +238,7 @@size_t len =strlen (buf);if (len >0 ) { -if (write (so->fd, buf, len) != len) +if (write (so->fd, buf, (unsigned int )len) != len) { so->errors = true; }
@@ -274,16 +269,14 @@/* read more of file into buffer */ if (c ==-1 ) { -int len; -ASSERT (buf_init (&so->read_buf,0 )); - len =read (so->fd,BPTR (&so->read_buf),BCAP (&so->read_buf)); +ssize_t len =read (so->fd,BPTR (&so->read_buf),BCAP (&so->read_buf));if (len <=0 ) {break ; } -ASSERT (buf_inc_len (&so->read_buf, len)); +ASSERT (buf_inc_len (&so->read_buf, (int )len));continue ; }
@@ -299,7 +292,7 @@break ; } -buf_write_u8 (buf, c); +buf_write_u8 (buf, (uint8_t )c); }buf_null_terminate (buf);
@@ -307,7 +300,3 @@return ret; } - -#if defined(__GNUC__) || defined(__clang__) -#pragma GCC diagnostic pop -#endif
--
To view, visit http://gerrit.openvpn.net/c/openvpn/+/1485?usp=email
To unsubscribe, or for help writing mail filters, visit http://gerrit.openvpn.net/settings?usp=email
Gerrit-MessageType: newpatchset
Gerrit-Project: openvpn
Gerrit-Branch: master
Gerrit-Change-Id: Iff1343a2f8cc7e32b8f36b359a00248e4dc3e8c9
Gerrit-Change-Number: 1485
Gerrit-PatchSet: 2
Gerrit-Owner: flichtenheld <[email protected]...>
Gerrit-Reviewer: plaisthos <[email protected]...>
Gerrit-CC: openvpn-devel <[email protected]>
Gerrit-Attention: plaisthos <[email protected]...>
Gerrit-Attention: flichtenheld <[email protected]...>
PATCH v2 1/1 status: Avoid conversion warnings in status_read/status_printf
In reply to a message not in the archiveJust use explicit casts. len is limited by BCAP and c is limited by being from buf_read_u8. So they are safe.
In case of status_printf this is only for Windows. len is limited by sizeof(buf), so also a safe cast.
Gerrit URL: https://gerrit.openvpn.net/c/openvpn/+/1485
---
This change was reviewed on Gerrit and approved by at least one developer. I request to merge it to master.
Gerrit URL: https://gerrit.openvpn.net/c/openvpn/+/1485
This mail reflects revision 2 of this Change.
Acked-by according to Gerrit (reflected above):
src/openvpn/status.c +4 -15
@@ -206,11 +206,6 @@return ret; } -#if defined(__GNUC__) || defined(__clang__) -#pragma GCC diagnostic push -#pragma GCC diagnostic ignored "-Wconversion" -#endif -#define STATUS_PRINTF_MAXLEN 512void
@@ -243,7 +238,7 @@size_t len =strlen (buf);if (len >0 ) { -if (write (so->fd, buf, len) != len) +if (write (so->fd, buf, (unsigned int )len) != len) { so->errors = true; }
@@ -274,16 +269,14 @@/* read more of file into buffer */ if (c ==-1 ) { -int len; -ASSERT (buf_init (&so->read_buf,0 )); - len =read (so->fd,BPTR (&so->read_buf),BCAP (&so->read_buf)); +ssize_t len =read (so->fd,BPTR (&so->read_buf),BCAP (&so->read_buf));if (len <=0 ) {break ; } -ASSERT (buf_inc_len (&so->read_buf, len)); +ASSERT (buf_inc_len (&so->read_buf, (int )len));continue ; }
@@ -299,7 +292,7 @@break ; } -buf_write_u8 (buf, c); +buf_write_u8 (buf, (uint8_t )c); }buf_null_terminate (buf);
@@ -307,7 +300,3 @@return ret; } - -#if defined(__GNUC__) || defined(__clang__) -#pragma GCC diagnostic pop -#endif
[Openvpn-devel] [PATCH applied] Re: status: Avoid conversion warnings in status_read/status_printf
I was a bit sceptical on the call to write(), but this is a windows annoyance again - all reasonable platforms have a size_t here, and windows uses an (unsigned int), triggering a senseless warning on mingw. Meh. The other changes are straightforward "use the correct types and cast where unavoidable"
Your patch has been applied to the master branch.
commit e1e3b9aed13d42fd5e298bec5b079598fdf3a04e
Author: Frank Lichtenheld Date: Thu Jan 22 16:47:51 2026 +0100
status: Avoid conversion warnings in status_read/status_printf
Signed-off-by: Frank Lichtenheld <[email protected]...>
Gerrit URL: https://gerrit.openvpn.net/c/openvpn/+/1485
Message-Id: <[email protected]...>
URL: https://www.mail-archive.com/[email protected]/msg35398.html
Signed-off-by: Gert Doering <[email protected]...>--
kind regards,
Gert Doering
[Openvpn-devel] [S] Change in openvpn[master]: status: Avoid conversion warnings in status_read/status_printf
In reply to a message not in the archiveAttention is currently required from: flichtenheld, plaisthos.
cron2 has posted comments on this change by flichtenheld. ( http://gerrit.openvpn.net/c/openvpn/+/1485?usp=email )
Change subject: status: Avoid conversion warnings in status_read/status_printf
......................................................................
Patch Set 2: Code-Review-1
(1 comment)
File src/openvpn/status.c:
http://gerrit.openvpn.net/c/openvpn/+/1485/comment/d724e493_5742107d?usp=email :
PS2, Line 241: if (write(so->fd, buf, (unsigned int)len) != len)
this change confuses me. In my manpage, write() wants a size_t count (linux) or size_t nbytes (FreeBSD), and so size_t len should be perfectly fine.
--
To view, visit http://gerrit.openvpn.net/c/openvpn/+/1485?usp=email
To unsubscribe, or for help writing mail filters, visit http://gerrit.openvpn.net/settings?usp=email
Gerrit-MessageType: comment
Gerrit-Project: openvpn
Gerrit-Branch: master
Gerrit-Change-Id: Iff1343a2f8cc7e32b8f36b359a00248e4dc3e8c9
Gerrit-Change-Number: 1485
Gerrit-PatchSet: 2
Gerrit-Owner: flichtenheld <[email protected]...>
Gerrit-Reviewer: cron2 <[email protected]...>
Gerrit-Reviewer: plaisthos <[email protected]...>
Gerrit-CC: openvpn-devel <[email protected]>
Gerrit-Attention: plaisthos <[email protected]...>
Gerrit-Attention: flichtenheld <[email protected]...>
Gerrit-Comment-Date: Sat, 24 Jan 2026 18:21:35 +0000
Gerrit-HasComments: Yes
Gerrit-Has-Labels: Yes
[Openvpn-devel] [S] Change in openvpn[master]: status: Avoid conversion warnings in status_read/status_printf
In reply to a message not in the archiveAttention is currently required from: cron2, plaisthos.
flichtenheld has posted comments on this change by flichtenheld. ( http://gerrit.openvpn.net/c/openvpn/+/1485?usp=email )
Change subject: status: Avoid conversion warnings in status_read/status_printf
......................................................................
Patch Set 2:
(1 comment)
File src/openvpn/status.c:
http://gerrit.openvpn.net/c/openvpn/+/1485/comment/9696cdac_b218c0bb?usp=email :
PS2, Line 241: if (write(so->fd, buf, (unsigned int)len) != len)
Quoted 1 line
this change confuses me. […]
This is required for Windows (see https://learn.microsoft.com/en-us/cpp/c-runtime-library/reference/write?view=msvc-170)
In some of the places we have comments that this is for Windows (e.g. in test_ssl.c). Shall I add one here as well?
--
To view, visit http://gerrit.openvpn.net/c/openvpn/+/1485?usp=email
To unsubscribe, or for help writing mail filters, visit http://gerrit.openvpn.net/settings?usp=email
Gerrit-MessageType: comment
Gerrit-Project: openvpn
Gerrit-Branch: master
Gerrit-Change-Id: Iff1343a2f8cc7e32b8f36b359a00248e4dc3e8c9
Gerrit-Change-Number: 1485
Gerrit-PatchSet: 2
Gerrit-Owner: flichtenheld <[email protected]...>
Gerrit-Reviewer: cron2 <[email protected]...>
Gerrit-Reviewer: plaisthos <[email protected]...>
Gerrit-CC: openvpn-devel <[email protected]>
Gerrit-Attention: plaisthos <[email protected]...>
Gerrit-Attention: cron2 <[email protected]...>
Gerrit-Comment-Date: Mon, 26 Jan 2026 12:47:43 +0000
Gerrit-HasComments: Yes
Gerrit-Has-Labels: No
Comment-In-Reply-To: cron2 <[email protected]...>
[Openvpn-devel] [S] Change in openvpn[master]: status: Avoid conversion warnings in status_read/status_printf
In reply to a message not in the archiveAttention is currently required from: cron2.
cron2 has uploaded a new patch set (#3) to the change originally created by flichtenheld. ( http://gerrit.openvpn.net/c/openvpn/+/1485?usp=email )
The following approvals got outdated and were removed:
Code-Review-1 by cron2
Change subject: status: Avoid conversion warnings in status_read/status_printf
......................................................................
status: Avoid conversion warnings in status_read/status_printf
Just use explicit casts. len is limited by BCAP and c is limited by being from buf_read_u8. So they are safe.
In case of status_printf this is only for Windows. len is limited by sizeof(buf), so also a safe cast.
Gerrit URL: https://gerrit.openvpn.net/c/openvpn/+/1485
Message-Id: <[email protected]...>
URL: https://www.mail-archive.com/[email protected]/msg35398.html
---
M src/openvpn/status.c
1 file changed, 4 insertions(+), 15 deletions(-)
git pull ssh://gerrit.openvpn.net:29418/openvpn refs/changes/85/1485/3
src/openvpn/status.c +4 -15
@@ -206,11 +206,6 @@return ret; } -#if defined(__GNUC__) || defined(__clang__) -#pragma GCC diagnostic push -#pragma GCC diagnostic ignored "-Wconversion" -#endif -#define STATUS_PRINTF_MAXLEN 512void
@@ -243,7 +238,7 @@size_t len =strlen (buf);if (len >0 ) { -if (write (so->fd, buf, len) != len) +if (write (so->fd, buf, (unsigned int )len) != len) { so->errors = true; }
@@ -274,16 +269,14 @@/* read more of file into buffer */ if (c ==-1 ) { -int len; -ASSERT (buf_init (&so->read_buf,0 )); - len =read (so->fd,BPTR (&so->read_buf),BCAP (&so->read_buf)); +ssize_t len =read (so->fd,BPTR (&so->read_buf),BCAP (&so->read_buf));if (len <=0 ) {break ; } -ASSERT (buf_inc_len (&so->read_buf, len)); +ASSERT (buf_inc_len (&so->read_buf, (int )len));continue ; }
@@ -299,7 +292,7 @@break ; } -buf_write_u8 (buf, c); +buf_write_u8 (buf, (uint8_t )c); }buf_null_terminate (buf);
@@ -307,7 +300,3 @@return ret; } - -#if defined(__GNUC__) || defined(__clang__) -#pragma GCC diagnostic pop -#endif
--
To view, visit http://gerrit.openvpn.net/c/openvpn/+/1485?usp=email
To unsubscribe, or for help writing mail filters, visit http://gerrit.openvpn.net/settings?usp=email
Gerrit-MessageType: newpatchset
Gerrit-Project: openvpn
Gerrit-Branch: master
Gerrit-Change-Id: Iff1343a2f8cc7e32b8f36b359a00248e4dc3e8c9
Gerrit-Change-Number: 1485
Gerrit-PatchSet: 3
Gerrit-Owner: flichtenheld <[email protected]...>
Gerrit-Reviewer: cron2 <[email protected]...>
Gerrit-Reviewer: plaisthos <[email protected]...>
Gerrit-CC: openvpn-devel <[email protected]>
Gerrit-Attention: cron2 <[email protected]...>
[Openvpn-devel] [S] Change in openvpn[master]: status: Avoid conversion warnings in status_read/status_printf
In reply to a message not in the archiveAttention is currently required from: cron2.
cron2 has submitted this change. ( http://gerrit.openvpn.net/c/openvpn/+/1485?usp=email )
Change subject: status: Avoid conversion warnings in status_read/status_printf
......................................................................
status: Avoid conversion warnings in status_read/status_printf
Just use explicit casts. len is limited by BCAP and c is limited by being from buf_read_u8. So they are safe.
In case of status_printf this is only for Windows. len is limited by sizeof(buf), so also a safe cast.
Gerrit URL: https://gerrit.openvpn.net/c/openvpn/+/1485
Message-Id: <[email protected]...>
URL: https://www.mail-archive.com/[email protected]/msg35398.html
---
M src/openvpn/status.c
1 file changed, 4 insertions(+), 15 deletions(-)
src/openvpn/status.c +4 -15
@@ -206,11 +206,6 @@return ret; } -#if defined(__GNUC__) || defined(__clang__) -#pragma GCC diagnostic push -#pragma GCC diagnostic ignored "-Wconversion" -#endif -#define STATUS_PRINTF_MAXLEN 512void
@@ -243,7 +238,7 @@size_t len =strlen (buf);if (len >0 ) { -if (write (so->fd, buf, len) != len) +if (write (so->fd, buf, (unsigned int )len) != len) { so->errors = true; }
@@ -274,16 +269,14 @@/* read more of file into buffer */ if (c ==-1 ) { -int len; -ASSERT (buf_init (&so->read_buf,0 )); - len =read (so->fd,BPTR (&so->read_buf),BCAP (&so->read_buf)); +ssize_t len =read (so->fd,BPTR (&so->read_buf),BCAP (&so->read_buf));if (len <=0 ) {break ; } -ASSERT (buf_inc_len (&so->read_buf, len)); +ASSERT (buf_inc_len (&so->read_buf, (int )len));continue ; }
@@ -299,7 +292,7 @@break ; } -buf_write_u8 (buf, c); +buf_write_u8 (buf, (uint8_t )c); }buf_null_terminate (buf);
@@ -307,7 +300,3 @@return ret; } - -#if defined(__GNUC__) || defined(__clang__) -#pragma GCC diagnostic pop -#endif
--
To view, visit http://gerrit.openvpn.net/c/openvpn/+/1485?usp=email
To unsubscribe, or for help writing mail filters, visit http://gerrit.openvpn.net/settings?usp=email
Gerrit-MessageType: merged
Gerrit-Project: openvpn
Gerrit-Branch: master
Gerrit-Change-Id: Iff1343a2f8cc7e32b8f36b359a00248e4dc3e8c9
Gerrit-Change-Number: 1485
Gerrit-PatchSet: 3
Gerrit-Owner: flichtenheld <[email protected]...>
Gerrit-Reviewer: cron2 <[email protected]...>
Gerrit-Reviewer: plaisthos <[email protected]...>
Gerrit-CC: openvpn-devel <[email protected]>
Gerrit-Attention: cron2 <[email protected]...>